<template>
    <div class="search">
        <div class="search-box">
            <el-input v-model="search" placeholder="请输入搜索内容" class="input-with-select"></el-input>
            <el-button class="search-btn" type="primary" @click="searchTask"><el-icon>
                    <Search />
                </el-icon>搜索</el-button>
        </div>
    </div>
    <div class="task-list">
        <el-table :data="tableData" style="width: 100%">
            <el-table-column prop="id" label="ID" width="180"> </el-table-column>
            <el-table-column prop="name" label="任务名称" width="180"> </el-table-column>
            <el-table-column prop="status" label="状态" width="180"> </el-table-column>
            <el-table-column prop="publish_time" label="发布时间" width="180"> </el-table-column>
            <el-table-column prop="address" label="地址" max-width="100"></el-table-column>
            <el-table-column fixed="right" label="操作" width="120">
                <template #default="scope">
                    <el-button type="primary" @click.prevent="edit(scope.$index)">
                        立即抢单
                    </el-button>
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>

<script setup>
import { ref } from "vue";

const search = ref("");
const searchTask = () => {
    tableData.value = tableData.value.filter((item) => {
        return item.name.includes(search.value);
    });
};
const tableData = ref([
    {
        id: 1,
        name: "任务1",
        status: "进行中",
        publish_time: "2021-01-01",
        address: "广东省广州市",
    },
    {
        id: 2,
        name: "任务2",
        status: "进行中",
        publish_time: "2021-01-01",
       address: "广东省广州市",
        address: "广东省广州市",
    },
    {
        id: 3,
        name: "任务3",
        status: "进行中",
        publish_time: "2021-01-01",
        address: "广东省广州市",
    }
]);
</script>

<style scoped>
.search {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.search-box {
    width: 50%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.search-btn {
    margin-left: 20px;
}

.task-list {
    margin-top: 20px;
}
</style>